package logic

import (
	"context"
	"zhihu/zhihuRpc/zhihuRpc"

	"zhihu/api/internal/svc"
	"zhihu/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type QuestionHotListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewQuestionHotListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QuestionHotListLogic {
	return &QuestionHotListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *QuestionHotListLogic) QuestionHotList(req *types.QuestionHotListRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	list, err := l.svcCtx.ZhiHuRpc.QuestionHotList(l.ctx, &zhihuRpc.QuestionHotListRequest{})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "热度top10排行榜获取成功",
		Code:    200,
		Data:    list,
	}, nil
}
